# -*- encoding: utf-8 -*-
from odoo import models, fields, api


class ProductTemplate(models.Model):
    _inherit = 'product.template'

    is_finished = fields.Boolean(string=u'Is Product', compute='_get_categ_id', store=True)
    is_materiel = fields.Boolean(string=u'Is Materiel', compute='_get_categ_id', store=True)

    @api.depends('categ_id')
    def _get_categ_id(self):
        for item in self:
            finished_id = self.env.ref('sb_sale.finished_product_type').id
            semi_id = self.env.ref('sb_sale.semi_product_type').id
            is_finished, is_semi = False, False
            if item.categ_id and item.categ_id.id == finished_id or item.categ_id and item.categ_id.id == semi_id:
                is_finished = True
                is_materiel = False
            else:
                is_finished = False
                is_materiel = True
            item.is_finished = is_finished
            item.is_materiel = is_materiel